import { injectable, inject } from 'inversify'
import { UserDto } from './user.dto'
import { plainToClass } from 'class-transformer'
import { validate } from 'class-validator'

/**
 * ## User 逻辑层
 */
@injectable()
export class UserServices {
  constructor() { }

  /** 登录逻辑 */
  public async get() {
    // 执行查询逻辑
    return 'get success'
  }

  /** 注册逻辑 */
  public async post(user: UserDto) {
    let userDto = plainToClass(UserDto, user)
    const errors = await validate(userDto)
    console.log(errors);

    return 'post success'
  }
}